package itsm.isperp.module.service.incident;

import itsm.isperp.framework.service.BaseService;
import itsm.isperp.module.entity.app.AppUser;
import itsm.isperp.module.entity.incident.IcdCategoryRelamembers;
import itsm.isperp.module.repository.incident.IcdCategoryRelamembersMapper;
import itsm.isperp.workflow.utils.BpmConst;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * 服务
 * 
 * @author lizx
 * @date 2015-04-05 12:21
 */
@Service
public class IcdCategoryRelamembersService extends
		BaseService<IcdCategoryRelamembers> {

	@Autowired
	protected IcdCategoryRelamembersMapper icdCategoryRelamembersMapper;

	@Override
	public IcdCategoryRelamembersMapper getRepository() {
		return this.icdCategoryRelamembersMapper;
	}

	public List<Map<String, Object>> getIcdCategoryRelamembers(String categoryId) {

		return this.icdCategoryRelamembersMapper
				.getIcdCategoryRelamembers(categoryId);
	}
	
	public List<Map<String, Object>> findAllMemberByCategoryId(String categoryId) {

		String userProcessSql = " LEFT JOIN (SELECT COUNT(task_executer) AS process_count,task_executer FROM ( "
				+ BpmConst.getQueryTaskSql("incidentProcess")
				+ ")t GROUP BY task_executer)t ON t.task_executer=b.name ";

		return this.icdCategoryRelamembersMapper.findAllMemberByCategoryId(categoryId,userProcessSql);

	}
	
	public List<AppUser> findRelaAppUserByCategoryIdAndRole(String categoryId,String roleName) {
		return this.icdCategoryRelamembersMapper.findRelaAppUserByCategoryIdAndRole(categoryId, roleName);

	}
	
	
	

	 

}
